/*!
 * 所有的接口列表
 */

'use strict';
const Router = require('koa-router');
const router = new Router();
const controller = require('../controller');

const routerMap = [
  // ----  不需要登录校验的接口
  ['POST','/v1/login', controller.user.login],
  ['GET', '/v1/logout', controller.user.logout],
  
  // ----  需要登录较校验的接口
  ['GET', '/test', controller.user.getUserInfo],
];

let apiArr = [];
routerMap.forEach((row) => {
  const method = row[0];
  const path = row[1];
  apiArr.push([method, path].join(' '));
});

const route = () => {
  routerMap.forEach((row) => {
    const method = row[0].toLocaleLowerCase();
    const path = row[1];
    const handleFn = row[2];

    router[method](path, handleFn);
  });

  return router;
}

module.exports.route = route;